<?php
namespace App\Socket\Logic;


class DeckCards{
    private $CName=["Three","Four","Five","Six","Seven","Eight","Nine","Ten","Jack","Queen","King","One","Two","SJoker","LJoker"];
    private $CColor = ["Spade","Heart","Club","Square"];

    protected $cards;
    /** 创建一副牌 */
    public function create(){        
        foreach($this->CName as $name){
            foreach($this->CColor as $color){
                if($name!="SJoker" && $name!="LJoker"){                    
                    $this->cards[] = new Card($name,$color);
                }   
            }
        }
        $this->cards[] = new Card("SJoker");
        $this->cards[] = new Card("LJoker");       
        shuffle($this->cards);        
        return $this;
    }
    public function getCards($num){
        $res = array_splice($this->cards,0,$num);        
        //对手牌进行排序
        usort($res,function($a,$b){
            return $a->getValue() <=> $b->getValue();
        });
        return $res;
    }
    public function getBottom(){
        return array_slice($this->cards,-3,3);        
    }
}

